package com.ruoyi.web.controller.gym;

import com.ny.domain.FitnessProductDO;
import com.ny.domain.ProductPurchaseDO;
import com.ny.dto.CreateGroup;
import com.ny.dto.DeleteGroup;
import com.ny.dto.FitnessProductDTO;
import com.ny.dto.PurchaseRecordDTO;
import com.ny.dto.RestResult;
import com.ny.dto.UpdateGroup;
import com.ny.query.QueryGroup;
import com.ny.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.lang.Boolean;
import java.lang.Integer;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品管理
 *
 * @author MSI-NB
 * @date 2025-03-08 13:14:38
 */
@Api("商品管理")
@RequestMapping("product")
@RestController
public class ProductController {

    @Autowired
    private ProductService productService;

    /**
     * 接口名称: 获取所有健身商品
     *
     * @return
     */
    @RequestMapping(value = "/all", method = RequestMethod.GET)
    @ApiOperation("接口名称: 获取所有健身商品")
    public RestResult<List<FitnessProductDO>> getAllFitnessProducts() {
        List<FitnessProductDO> result = productService.getAllFitnessProducts();
        return RestResult.success(result);
    }

    /**
     * 接口名称: 获取指定ID健身商品
     *
     * @param productId
     * @return
     */
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    @ApiOperation("接口名称: 获取指定ID健身商品")
    public RestResult<FitnessProductDO> getFitnessProductById(@Validated(QueryGroup.class) Integer productId) {
        FitnessProductDO result = productService.getFitnessProductById(productId);
        return RestResult.success(result);
    }

    /**
     * 接口名称: 新增健身商品
     *
     * @param fitnessProductDTO 健身商品的DTO
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation("接口名称: 新增健身商品")
    @ResponseBody
    public RestResult<Boolean> addFitnessProduct(@RequestBody @Validated(CreateGroup.class) FitnessProductDTO fitnessProductDTO) {
        Boolean result = productService.addFitnessProduct(fitnessProductDTO);
        return RestResult.success(result);
    }

    /**
     * 接口名称: 更新健身商品
     *
     * @param fitnessProductDTO 健身商品的DTO
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.PUT)
    @ApiOperation("接口名称: 更新健身商品")
    @ResponseBody
    public RestResult<Boolean> updateFitnessProduct(@RequestBody @Validated(UpdateGroup.class) FitnessProductDTO fitnessProductDTO) {
        Boolean result = productService.updateFitnessProduct(fitnessProductDTO);
        return RestResult.success(result);
    }

    /**
     * 接口名称: 删除健身商品
     *
     * @param productId
     * @return
     */
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    @ApiOperation("接口名称: 删除健身商品")
    public RestResult<Boolean> deleteFitnessProduct(@Validated(DeleteGroup.class) Integer productId) {
        Boolean result = productService.deleteFitnessProduct(productId);
        return RestResult.success(result);
    }

    /**
     * 接口名称: 获取会员所有购买记录
     *
     * @param memberId
     * @return
     */
    @RequestMapping(value = "/purchase/all", method = RequestMethod.GET)
    @ApiOperation("接口名称: 获取会员所有购买记录")
    public RestResult<List<ProductPurchaseDO>> getAllPurchaseRecordsByMemberId(@Validated(QueryGroup.class) Integer memberId) {
        List<ProductPurchaseDO> result = productService.getAllPurchaseRecordsByMemberId(memberId);
        return RestResult.success(result);
    }

    /**
     * 接口名称: 获取指定ID购买记录
     *
     * @param purchaseId
     * @return
     */
    @RequestMapping(value = "/purchase/info", method = RequestMethod.GET)
    @ApiOperation("接口名称: 获取指定ID购买记录")
    public RestResult<ProductPurchaseDO> getPurchaseRecordById(@Validated(QueryGroup.class) Integer purchaseId) {
        ProductPurchaseDO result = productService.getPurchaseRecordById(purchaseId);
        return RestResult.success(result);
    }

    /**
     * 接口名称: 新增购买记录
     *
     * @param purchaseRecordDTO 购买记录的DTO
     * @return
     */
    @RequestMapping(value = "/purchase/add", method = RequestMethod.POST)
    @ApiOperation("接口名称: 新增购买记录")
    @ResponseBody
    public RestResult<Boolean> addPurchaseRecord(@RequestBody @Validated(CreateGroup.class) PurchaseRecordDTO purchaseRecordDTO) {
        Boolean result = productService.addPurchaseRecord(purchaseRecordDTO);
        return RestResult.success(result);
    }

    /**
     * 接口名称: 更新购买记录
     *
     * @param purchaseRecordDTO 购买记录的DTO
     * @return
     */
    @RequestMapping(value = "/purchase/update", method = RequestMethod.PUT)
    @ApiOperation("接口名称: 更新购买记录")
    @ResponseBody
    public RestResult<Boolean> updatePurchaseRecord(@RequestBody @Validated(UpdateGroup.class) PurchaseRecordDTO purchaseRecordDTO) {
        Boolean result = productService.updatePurchaseRecord(purchaseRecordDTO);
        return RestResult.success(result);
    }

    /**
     * 接口名称: 删除购买记录
     *
     * @param purchaseId
     * @return
     */
    @RequestMapping(value = "/purchase/delete", method = RequestMethod.DELETE)
    @ApiOperation("接口名称: 删除购买记录")
    public RestResult<Boolean> deletePurchaseRecord(@Validated(DeleteGroup.class) Integer purchaseId) {
        Boolean result = productService.deletePurchaseRecord(purchaseId);
        return RestResult.success(result);
    }
}
